import type { Meta, StoryObj } from "@storybook/react";
import { fn } from "@storybook/test";
import "../../styles/index.scss";
import { library } from "@fortawesome/fontawesome-svg-core";
import { fas } from "@fortawesome/free-solid-svg-icons";
import Upload from "./upload";
import { action } from "@storybook/addon-actions";
import { log } from "console";
import Button from "../Button/Button";
library.add(fas);
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta = {
  title: "components/Upload",
  component: Upload,
  parameters: {
    // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
    layout: "centered",
  },
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
  tags: ["autodocs"],
  // More on argTypes: https://storybook.js.org/docs/api/argtypes
  argTypes: {},
  // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
  args: {},
} satisfies Meta<typeof Upload>;

export default meta;
type Story = StoryObj<typeof meta>;
const checkFileSize = (file: File) => {
  if (Math.round(file.size / 1024) > 50) {
    alert("file is too large");
    return false;
  }
  return true;
};
const filePromise = (file: File) => {
  const newFile = new File([file], "new_name.docx", {
    type: file.type,
  });
  return Promise.resolve(newFile);
};
export const DefaultUpload: Story = {
  args: {
    action: "https://jsonplaceholder.typicode.com/posts",
    children: <Button>upload</Button>,
  },
  render: (args) => (
    <>
      <Upload action={args.action} children={args.children}></Upload>
    </>
  ),
};

export const DragUpload: Story = {
  args: {
    action: "https://jsonplaceholder.typicode.com/posts",
    children: <Button>upload</Button>,
  },
  render: (args) => (
    <>
      <Upload action={args.action} children={args.children} drag></Upload>
    </>
  ),
};

export const MultipleUpload: Story = {
  args: {
    action: "https://jsonplaceholder.typicode.com/posts",
    children: <Button>upload</Button>,
  },
  render: (args) => (
    <div>
      <Upload action={args.action} children={args.children} multiple></Upload>
    </div>
  ),
};
